using System;
using System.Reflection;
using WCSFContrib.Extensions.EventBroker;

namespace WCSFContrib.Extensions.CompositeWeb
{
	/// <summary>
	/// An event broker with a per request scope. During build up publishers and subscribers are added.
	/// At Dispose delegate handlers are removed from each publishing event.
	/// </summary>
	public interface IRequestEventBroker : IDisposable
	{
		/// <summary>
		/// Add publication of a topic from the instance.
		/// </summary>
		/// <param name="data">Topic and EventInfo</param>
		/// <param name="instance">Publising instance</param>
		void AddPublisher(object instance, MemberReference<EventInfo> data);

		/// <summary>
		/// Add subscription of a topic from the instance.
		/// </summary>
		/// <param name="data">Topic and MethodInfo</param>
		/// <param name="instance">Publising instance</param>
		void AddSubscriber(object instance, MemberReference<MethodInfo> data);

		/// <summary>
		/// Remove handler delegates from publisher events.
		/// </summary>
		new void Dispose();
	}
}